<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>用户信息</title>
    <style>
        /* 全局样式 */
        body {
            font-family: 'PingFang SC', 'Microsoft YaHei', sans-serif;
            background-color: #f5f7fa;
            margin: 0;
            padding: 0;
            color: #333;
            line-height: 1.6;
        }

        .container {
            display: flex;
            flex-wrap: wrap;
            gap: 30px;
            max-width: 1200px;
            margin: 50px auto;
            padding: 0 20px;
        }

        .left-panel {
            flex: 1;
            min-width: 300px;
            max-width: 350px;
            padding: 25px;
            background-color: #fff;
            border-radius: 12px;
            box-shadow: 0 5px 15px rgba(0, 0, 0, 0.08);
            transition: transform 0.3s ease;
        }

        .right-panel {
            flex: 2;
            min-width: 500px;
            padding: 25px;
            background-color: #fff;
            border-radius: 12px;
            box-shadow: 0 5px 15px rgba(0, 0, 0, 0.08);
            transition: transform 0.3s ease;
        }

        .left-panel:hover, .right-panel:hover {
            transform: translateY(-5px);
            box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
        }

        /* 标题样式 */
        .panel-title {
            margin-top: 0;
            color: #2c3e50;
            font-size: 20px;
            margin-bottom: 20px;
            padding-bottom: 10px;
            border-bottom: 1px solid #e8f5e9;
        }

        /* 用户头像 */
        .avatar {
            width: 120px;
            height: 120px;
            border-radius: 50%;
            object-fit: cover;
            border: 3px solid #e0f2f1;
            margin-bottom: 15px;
            display: block;
            margin-left: auto;
            margin-right: auto;
            transition: transform 0.3s ease;
        }

        .avatar:hover {
            transform: scale(1.05);
        }

        /* 用户信息列表 */
        .info-list {
            list-style: none;
            padding-left: 0;
        }

        .info-list li {
            margin-bottom: 10px;
            color: #555;
            font-size: 14px;
        }

        .info-list strong {
            color: #2c3e50;
            font-weight: 600;
            display: inline-block;
            width: 80px;
        }

        /* 按钮样式 */
        .button-group {
            margin-top: 20px;
        }

        .btn {
            display: inline-block;
            padding: 8px 16px;
            background-color: #4CAF50;
            color: white;
            text-decoration: none;
            border-radius: 4px;
            font-size: 14px;
            transition: all 0.3s ease;
            border: none;
            cursor: pointer;
        }

        .btn:hover {
            background-color: #388e3c;
        }

        .btn-danger {
            background-color: #f44336;
        }

        .btn-danger:hover {
            background-color: #d32f2f;
        }

        /* 文章卡片样式 */
        .article-card {
            background-color: #fafafa;
            padding: 20px;
            border-radius: 8px;
            margin-bottom: 15px;
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
            transition: transform 0.3s ease;
            border-left: 3px solid #4CAF50;
        }

        .article-card:hover {
            transform: translateY(-3px);
            box-shadow: 0 5px 15px rgba(0, 0, 0, 0.15);
        }

        .article-card h4 {
            margin-top: 0;
            font-size: 16px;
            color: #2c3e50;
        }

        .article-card p {
            color: #666;
            line-height: 1.5;
            font-size: 14px;
            margin-bottom: 15px;
        }

        /* 无文章提示 */
        .empty-message {
            text-align: center;
            padding: 40px 0;
            color: #777;
            font-size: 16px;
        }

        /* 响应式设计 */
        @media (max-width: 768px) {
            .container {
                flex-direction: column;
            }
        }
    </style>
</head>
<body>

<div class="container">

    <!-- 左侧：用户信息 -->
    <div class="left-panel">
        <h3 class="panel-title">个人信息</h3>
        <div style="text-align: center;">
            <img th:src="@{${userInfo.image}}" alt="头像" class="avatar" />
            <p><strong th:text="${userInfo.name}"></strong></p>
        </div>

        <ul class="info-list">
            <li><strong>ID:</strong> <span th:text="${userInfo.id}"></span></li>
            <li><strong>邮箱:</strong> <span th:text="${userInfo.email}"></span></li>
            <li><strong>手机号:</strong> <span th:text="${userInfo.phone}"></span></li>
            <li><strong>地址:</strong> <span th:text="${userInfo.address}"></span></li>
            <li><strong>注册时间:</strong> <span th:text="${userInfo.createdAt}"></span></li>
        </ul>

        <div class="button-group">
            <a th:href="@{/user/update}" class="btn">修改信息</a>
            <a th:href="@{/user/index}" class="btn">返回首页</a>
        </div>

    </div>

    <!-- 右侧：文章列表 -->
    <div class="right-panel">
        <h3 class="panel-title">我的文章</h3>
        <div th:if="${#lists.isEmpty(userInfo.list)}" class="empty-message">
            <p>暂无文章。</p>
        </div>
        <div th:each="article : ${userInfo.list}">
            <div class="article-card">
                <h4 th:text="${article.title}"></h4>
                <p th:text="(${#strings.abbreviate(article.content, 120)}) + '...'"></p>
                <div class="button-group">
                    <a th:href="@{/article/edit/{id}(id=${article.id})}" class="btn">编辑文章</a>
                    <a th:action="@{/article/delete/{id}(id=${article.id})}" method="post" class="d-inline">
                        <button type="submit" class="btn btn-danger" onclick="return confirm('确定要删除这篇文章吗？')">删除文章</button>
                    </a>
                    <span th:if="${article.isApproved == null || article.isApproved == 0}" class="status status-pending">未发布</span>
                    <span th:if="${article.isApproved == 1}" class="status status-reviewing">审核中</span>
                    <span th:if="${article.isApproved == 2}" class="status status-approved">已发布</span>
                </div>
            </div>
        </div>
    </div>

</div>

</body>
</html>